package io.HomeWork;

import io.reader_.BufferReader_;

import java.io.*;
import java.util.Properties;

public class Homework01 {
    public static void main(String[] args) throws Exception {
        testBufferedReader();

    }
    public void testFile() throws IOException {
        String path = "d:/Test/mytemp";
        String text = "hello.txt";
        File file = new File(path);
        if (!file.exists()){
            file.mkdirs();
        }
        File file1 = new File(path, text);
        if (!file1.exists()){
            file.createNewFile();
        }else {
            System.out.println("文件已存在");
        }
    }
    public static void testBufferedReader() throws Exception {

        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream("d:/Test/create1.txt"),"GBK"));
        int i = 0;
        String readLean;
        while ((readLean = bufferedReader.readLine())!=null){
            i++;
            System.out.println(i+":" + readLean + "\r\n");
        }
        bufferedReader.close();
    }
    public static void testProperties() throws Exception {
        Properties properties = new Properties();
        properties.load(new FileReader("src/mysql.properties"));
        sql sql = new sql();
        sql.setPassword(properties.getProperty("password"));
        //...
    }
}
class sql implements Serializable{
    private static final long serialVersionUID = 1L;
    private String url;
    private String username;
    private String password;

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }
}